package com.cloudkinto.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhangyy
 * @date 2020/6/9 10:36
 * @description:
 */
public class OrderCodeUtil {

    //自发头程单号
    public static String getFirstVesselNumber(Long id) {
        return "FV" + formatSecond(new Date()) + id;
    }


    //入库单号
    public static String getOrderInputNumber(Long id) {
        return "IN" + formatSecond(new Date()) + id;
    }

    //fba入库单号
    public static String getFbaOrderInputNumber(Long id) {
        return "FIN" + formatSecond(new Date()) + id;
    }

    //fba出库单号
    public static String getFbaOrderOutputNumber(Long id) {
        return "FOT" + formatSecond(new Date()) + id;
    }


    //出库单号
    public static String getOrderOutNumber(Long id) {
        return "OT" + formatSecond(new Date()) + id;
    }

    //工单号
    public static String getWorkOrderNumber(Long id) {
        return "WO" + formatSecond(new Date()) + id;
    }

    //头程货柜编码
    public static String getHeaderContainerNumber(Long id) {
        return "HCN" + formatSecond(new Date()) + id;
    }

    //尾程约车单号
    public static String getTailTrucksNumber(Long id) {
        return "TAT" + formatSecond(new Date()) + id;
    }

    //生成公司编码
    public static String generateCompanyCode(Long id) {
        if (id > 999) {
            return "C" + id;
        } else {
            return "C1" + id;
        }
    }

    private static String formatSecond(Date date) {
        if (date == null) return null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(date);
    }
    private static String formatSecondSimpleYear(Date date) {
        if (date == null) return null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        return sdf.format(date);
    }


    public static String getBackOrderNumber(Long id) {
        return "BO" + formatSecond(new Date()) + id;
    }

    //工单号
    public static String getOrderReplaceNumber(Long id) {
        return "PJ" + formatSecond(new Date()) + id;
    }

    public static String getFbaBackOrderNumber(Long id) {
        return "FOB" + formatSecondSimpleYear(new Date()) + id;
    }
}
